#!/bin/csh -f
## must be run from thrun directory!
# cd-s to deco directory that must have deco.TM and th.inp
set dd=$DECAHOME/scripts
set thdir=`awk '$1=="thdir"{print $2}' mktm.def`
set rn=`awk '$1=="rootname"{print $2}' mktm.def`
#if(! -f $thdir/deco.TM) then
#    echo "Missing decofile $thdir/deco.TM"
#    exit
#endif
set mdir=`pwd`
cd $thdir
echo "$mdir:t/$rn.M -> th.inp"
$dd/thsums -nofig $mdir/$rn.M > th.M
echo "$mdir:t/""x2.L -> th.inp"
$dd/thsums -nofig $mdir/"x2".L > th.L
cd $mdir
cat $thdir/th.M | awk 'FNR==2{for(i=2;i<=NF;i++){printf(" %4s",$i)};print ""}FNR>2{for(i=2;i<=NF;i++){printf(" %4i",$i)};print "  M"$1}' > th.inp
cat $thdir/th.L | awk 'FNR>2{for(i=2;i<=NF;i++){printf(" %4i",$i)};print "  L"$1}' >> th.inp
##
